package com.hktf.uilib.engine;


import com.google.gson.JsonObject;
import com.hktf.corelib.constant.Api;
import com.hktf.corelib.jsonbean.response.BooleanResult;
import com.hktf.corelib.jsonbean.response.CommonResult;
import com.hktf.corelib.jsonbean.response.GetGoodsResult;
import com.hktf.corelib.jsonbean.response.GetWxAppPayParamsResult;
import com.hktf.corelib.jsonbean.response.LoginResult;
import com.hktf.corelib.jsonbean.response.StringResult;
import com.hktf.corelib.jsonbean.response.YaoQingRecordResult;
import com.hktf.corelib.utils.Config;
import com.hktf.corelib.utils.GsonUtils;
import com.hktf.uilib.callback.BaseCallBackNew;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

/**
 * @author 陈大专
 * @time 2024/6/19 14:31
 * @des
 **/
public class DriverEngine {

    public static void wxLogin(String code, BaseCallBackNew<LoginResult> callBack) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("code", code);
        jsonObject.addProperty("clientName", Config.CLIENTNAME);
        String url=Config.SERVER_URL + Api.WX_LOGIN;
        OkGo.<LoginResult>post(url)
                .upJson(GsonUtils.createGsonString(jsonObject))
                .execute(callBack);
    }
    public static void userLogoff(BaseCallBackNew<CommonResult> callBack) {
        String url=Config.SERVER_URL + Api.USER_LOGOFF+Config.USERINFO.getUserId();
        OkGo.<CommonResult>get(url)
                .execute(callBack);
    }
    public static void userRefresh(BaseCallBackNew<LoginResult> callBack) {
        String url=Config.SERVER_URL + Api.USER_REFRESH+Config.USERINFO.getUserId();
        OkGo.<LoginResult>get(url)
                .execute(callBack);
    }
    public static void goodsList(BaseCallBackNew<GetGoodsResult> callBack) {
        String url=Config.SERVER_URL + Api.GOODS_LIST+Config.CLIENTNAME;
        OkGo.<GetGoodsResult>get(url)
                .execute(callBack);
    }
    public static void getWxPayParams(Integer gid,BaseCallBackNew<GetWxAppPayParamsResult> callBack) {
        String url=Config.SERVER_URL + Api.WX_PAY_GET_PAY_PARAMS;
        OkGo.<GetWxAppPayParamsResult>post(url)
                .params("userId",  Config.USERINFO.getUserId())
                .params("clientName", Config.CLIENTNAME)
                .params("gid", gid)
                .execute(callBack);
    }
    public static void queryWxPayByOrderId(String orderId, BaseCallBackNew<LoginResult> callBack) {
        String url=Config.SERVER_URL + Api.ORDER_INFO+orderId;
        OkGo.<LoginResult>get(url)
                .execute(callBack);
    }

    public static void yaoqingSubmit(String code,BaseCallBackNew<LoginResult> callBack) {
        String url=Config.SERVER_URL + Api.yaoqing_submit;
        OkGo.<LoginResult>post(url)
                .params("userId",  Config.USERINFO.getUserId())
                .params("code", code)
                .execute(callBack);
    }
    public static void yaoqingList(BaseCallBackNew<YaoQingRecordResult> callBack) {
        String url=Config.SERVER_URL + Api.yaoqing_list+Config.USERINFO.getUserId();
        OkGo.<YaoQingRecordResult>get(url)
                .execute(callBack);
    }
    public static void sendFeedBack(String content,BaseCallBackNew<BooleanResult> callBack) {
        String url=Config.SERVER_URL + Api.FEED_BACK;
        OkGo.<BooleanResult>post(url)
                .params("userId",  Config.USERINFO.getUserId())
                .params("content", content)
                .params("clientName", Config.CLIENTNAME)
                .params("type", 0)
                .execute(callBack);
    }
    public static void getDujitang(BaseCallBackNew<StringResult> callBack) {
        String url=Config.SERVER_URL + Api.DUJITANG_GETONE;
        OkGo.<StringResult>get(url)
                .params("userId",  Config.USERINFO.getUserId())
                .params("clientName", Config.CLIENTNAME)
                .execute(callBack);
    }

}
